package tp.pr2;

public class Instruction {
	
	/**
	 * Constructores varios para parametros fallidos, accion, o accion con movimiento
	 */
	public Instruction (){
	}
	public Instruction (Action action){
		this.action = action;
	}
	public Instruction (Action action, Rotation rotation){
		this.action = action;
		this.rotation = rotation;
	}
	public Instruction (Action action, String id) {
		this.action = action;
		this.id = id;
	}
	
	/**
	 * gets the action defined by the instruction
	 * @return Accion de la instruccion
	 */
	public Action getAction (){
		return this.action;
	}
	/**
	 * gets the rotation stored in the instruction
	 * @return Rotacion de la instruccion
	 */
	public Rotation getRotation (){
		return this.rotation;
	}
	/**
	 * gets the item identifier stored in the instruction
	 * @return
	 */
	public String getId(){
		return this.id;
	}
	
	/**
	 * 
	 * @return si la instruccion es valida (tiene comando válido en el primer miembro y si es turn en el segundo tambien)
	 */
	public boolean isValid (){
		boolean instNoParam = this.action.equals(Action.MOVE) || this.action.equals(Action.HELP) || this.action.equals(Action.QUIT) || this.action.equals(Action.SCAN); 
		boolean instTurn = this.action.equals(Action.TURN) && !this.rotation.equals(Rotation.UNKNOWN);
		boolean instItem = (this.action.equals(Action.PICK) || this.action.equals(Action.OPERATE)) && !this.id.equals(""); 

		return instNoParam || instTurn || instItem;
	}
	
	private Action action = Action.UNKNOWN;
	private Rotation rotation = Rotation.UNKNOWN;
	private String id = "";
	
}
